{% extends "base.html" %}
{% load services %}

{% block title %}Group: {{group_name}}{% endblock %}

{% block header %}
    <h1>{{group_name}}</h1>
{% endblock %}

{% block content %}

<h2>Hosts</h2>
<table>
    <tr>
    {% for host in hosts %}
        <td class="state_{{ host.current_state|state_name|lower }}">
            <a href="{% url railroad.viewhosts.views.hostconfigurator host.host_name %}">{{host.host_name}}</a>
        </td>
        {% if forloop.counter|divisibleby:"5" %}</tr><tr>{% endif %}
    {% endfor %}
    </tr>
</table>
<br />
<h2>Services</h2>
<table>
<tr>
{% regroup services|dictsort:"nagcat_template" by nagcat_template as test_services %}
{% for test in test_services %}
    {% ifequal test.list|length 1 %}
        <td>
            <a href="{% url railroad.viewhosts.views.directconfigurator %}?services={{ test.list.0.service_description|urlencode }}&groups={{ group_name|urlencode }}">
                {{test.list.0.service_description}}
            </a>
        </td>
    {% else %}
        <td class="twirler">
            <span class="target">
                {% ifequal test.grouper "" %}
                    No Test
                {% else %}
                    {{ test.grouper }}
                    <a href="{% url railroad.viewhosts.views.directconfigurator %}?tests={{ test.grouper|urlencode }}&group={{ group_name|urlencode}} %}">
                        <div class="sprite arrow_e hover"></div>
                    </a>
                {% endifequal %}
            </span>
            <ul>
                {% for service in test.list|dictsort:"service_description" %}
                    <li>
                        <a href="{% url railroad.viewhosts.views.directconfigurator %}?services={{ service.service_description|urlencode }}&groups={{ group_name|urlencode }}">
                            {{service.service_description}}
                        </a>
                    </li>
                {% endfor %}
            </ul>
        </td>
    {% endifequal %}
    {% if forloop.counter|divisibleby:"2" %}</tr><tr>{% endif %}
{% endfor %}
</tr>
</table>
{% endblock %}
